﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.student
{
    public partial class RepaireReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Panel1.Visible = false;
        }

        protected void repair_Click(object sender, EventArgs e)
        {
                Panel1.Visible = true;
        }

        [Obsolete]
        protected void submit_Click(object sender, EventArgs e)
        {
            //执行
            try
            {
                using (MySqlConnection conn = new MySqlConnection(util.MySqlHelper.ConnStr))
                {
                    conn.Open();
                    string name1 = name.Text;
                    string address1 = address.Text;
                    string phone = phonenumber.Text;
                    string mes = message.Text;
                    string sql = "insert into dormitory_maintenance(name,address,message,phone,state) values ('" +
                        name1 + "','" + address1 + "','" + mes + "','" + phone + "','" + "0' )";
                    //获得MySsqlCommand
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    int result = cmd.ExecuteNonQuery();
                    if (result > 0)
                    {
                        name.Text = " ";
                        address.Text = " ";
                        phonenumber.Text = " ";
                        message.Text = " ";
                        Panel1.Visible = false;
                        this.Page.RegisterStartupScript(" ", "<script>alert(' 上报成功！ '); </script> ");
                    }
                    else
                    {
                        this.Page.RegisterStartupScript(" ", "<script>alert(' 上报失败！ '); </script> ");
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        protected void cancel_Click(object sender, EventArgs e)
        {
            name.Text = " ";
            address.Text = " ";
            phonenumber.Text = " ";
            message.Text = " ";
            Panel1.Visible = false;
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

    }
}